def find_word_concatenation(str1, words):
  result_indices = []
  word_map = { }
  char_length = len(words)*len(words[0])
  element_length = len(words[0])

  for i in words:
    if i not in word_map:
      word_map[i] = 0
    word_map[i] += 1

  for index in range(len(str1)-char_length+1):
    temp_map = {}
    for x in range(len(words)):
      next_index = index+x*element_length
      word = str1[next_index:next_index+element_length]
      if word not in word_map:
        break
      if word not in temp_map:
        temp_map[word] = 0
      temp_map[word] += 1

      if temp_map[word] > word_map.get(word,0):
        break

      if(x+1)==len(words):
        result_indices.append(index)


  # TODO: Write your code here
  return result_indices

def main():
  print(find_word_concatenation("catfoxcat", ["cat", "fox"]))
  print(find_word_concatenation("catcatfoxfox", ["cat", "fox"]))


main()
